package com.yl.auth.service.impl;

import com.yl.auth.model.entity.Chuangwei;
import com.yl.auth.mapper.ChuangweiMapper;
import com.yl.auth.service.ChuangweiService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yl
 * @since 2023-06-15
 * @author ln
 * @since 2023-06-16
 */
@Service
public class ChuangweiServiceImpl extends ServiceImpl<ChuangweiMapper, Chuangwei> implements ChuangweiService {
    @Resource
    private ChuangweiMapper chuangweiMapper;
    @Override
    public Chuangwei selectById(Long id) {
        Chuangwei chuangwei = chuangweiMapper.selectById(id);
        Integer count = 0;
        if (chuangwei.getId() != null) {
            // 检查当前床位是否有老人
            if (chuangwei.getLaorenId() != null) {
                count = 1;
            }
        }
        chuangwei.setCount(count);
        return chuangwei;
    }

    @Override
    public List<Chuangwei> getfindAll() {
        return chuangweiMapper.getfindAll();
    }
}
